package stub;

import java.rmi.RemoteException;

import databaseservice.BookPOService;
import databaseservice.CategoryPOService;
import databaseservice.MemberPOService;
import databaseservice.OrderPOService;
import info.OrderCondition;
import info.UserRole;
import po.BookPO;
import po.CategoryPO;
import po.MemberPO;
import po.OrderPO;
import po.UserPO;
import businesslogic.network.RMIStubClient;
import businesslogicservice.SMBLService;

public class SMBLService_Stub implements SMBLService{

	private MemberPOService mMemberPOService;
	private BookPOService mBookPOService;
	private CategoryPOService mCategoryPOService;
	private OrderPOService mOrderPOService;
	
	public SMBLService_Stub(RMIStubClient client){
		mMemberPOService=client.memberPOService;
		mOrderPOService=client.orderPOService;
		mBookPOService=client.bookPOService;
		mCategoryPOService=client.categoryPOService;
	}
	
	@Override
	public MemberPO checkUser(int UserID) {
		try {
			return mMemberPOService.search(1);
		} catch (RemoteException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return null;
		}
	}

	@Override
	public boolean send(int PresentID, UserPO userPO) {
		return true;
	}

	@Override
	public boolean changeCondition(OrderPO orderPO,
			OrderCondition orderCondition) {
		try {
			return mOrderPOService.alter(orderPO);
		} catch (RemoteException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return false;
		}
	}

	@Override
	public boolean addCategory(CategoryPO categoryPO) {
		try {
			return mCategoryPOService.add(categoryPO);
		} catch (RemoteException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return false;
		}
	}

	@Override
	public boolean deleteCategory(CategoryPO categoryPO) {
		try {
			return mCategoryPOService.delete(categoryPO);
		} catch (RemoteException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return false;
		}
	}

	@Override
	public boolean changeCategory(CategoryPO oldcategoryPO,
			CategoryPO newCategoryPO) {
		try {
			return mCategoryPOService.alter(newCategoryPO);
		} catch (RemoteException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return false;
		}
	}

	@Override
	public boolean addBook(BookPO bookPO) {
		try {
			return mBookPOService.add(bookPO);
		} catch (RemoteException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return false;
		}
	}

	@Override
	public boolean deleteBook(BookPO bookPO) {
		try {
			return mBookPOService.delete(bookPO);
		} catch (RemoteException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return false;
		}
	}

	@Override
	public boolean changeBook(BookPO oldBook, BookPO newBook) {
		try {
			return mBookPOService.alter(newBook);
		} catch (RemoteException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return false;
		}
	}
	
}
